package com.seven.mybatisx.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisxAutoConfig {

    /**
     * todo PaginationInterceptor 失效 应该换最新的
     *
     * @return
     */
    @Bean
    @ConditionalOnMissingBean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        return paginationInterceptor;
    }

    // 自定义拦截器实现模糊查询中的特殊字符处理
    @Bean
    @ConditionalOnMissingBean(SpecialCharactersInterceptor.class)
    public SpecialCharactersInterceptor myInterceptor() {
        SpecialCharactersInterceptor sql = new SpecialCharactersInterceptor();
        return sql;
    }
}
